home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Cafe 3
/
Visual Cafe 3.ISO
/
Vcafe
/
JFC.bin
/
HTMLBoxView.java
< prev
next >
Wrap
Text File
|
1998-06-30
|
2KB
|
89 lines
/*
* @(#)HTMLBoxView.java 1.4 97/09/30
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
package com.sun.java.swing.text.html;
import java.util.Enumeration;
import java.awt.*;
import com.sun.java.swing.border.*;
import com.sun.java.swing.text.*;
/**
* A view implementation to display an html box with
* CSS specifications.
*
* @author Timothy Prinzing
* @version 1.4 09/30/97
*/
class HTMLBoxView extends BoxView {
/**
* Creates a new view that represents an
* html box. This can be used for a number
* of elements.
*
* @param elem the element to create a view for
* @param axis either View.X_AXIS or View.Y_AXIS
*/
public HTMLBoxView(Element elem, int axis) {
super(elem, axis);
setParagraphInsets(elem.getAttributes());
}
/**
* Gets the resize weight.
*
* @param axis may be either X_AXIS or Y_AXIS
* @return the weight
* @exception IllegalArgumentException for an invalid axis
*/
public int getResizeWeight(int axis) {
switch (axis) {
case View.X_AXIS:
return 1;
case View.Y_AXIS:
return 0;
default:
throw new IllegalArgumentException("Invalid axis: " + axis);
}
}
/**
* Gets the alignment.
*
* @param axis may be either X_AXIS or Y_AXIS
* @return the alignment
*/
public float getAlignment(int axis) {
switch (axis) {
case View.X_AXIS:
return 0;
case View.Y_AXIS:
float span = getPreferredSpan(View.Y_AXIS);
View v = getView(0);
float above = v.getPreferredSpan(View.Y_AXIS);
float a = (((int)span) != 0) ? (above * v.getAlignment(View.Y_AXIS)) / span: 0;
return a;
default:
throw new IllegalArgumentException("Invalid axis: " + axis);
}
}
}